home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / V11N10.ARJ / SERTYPE.ASM < prev    next >
Assembly Source File  |  1992-04-30  |  2KB  |  98 lines

  1. «MDNM»; SERTYPE - A routine to determine the type of UART used in a serial«MDBO» «MDNM»;           port.
  2. ;
  3. ; Douglas Boling, Jan 1992
  4. ;
  5. ;
  6. ; Entry:  DX - Starting I/O address of the serial port
  7. ;
  8. ; Exit:  AL - Type of serial port
  9. ;
  10. ;         0 - 8250
  11. ;         1 - 16450, 16550, or 8250A
  12. ;         2 - 16550A with FIFO queues
  13. ;         3 - IBM Type 3 serial port with DMA
  14. ;
  15. ;=======================================================================
  16.  
  17. sertype        proc    near
  18.         push    bx
  19.         push    cx
  20.         mov    bx,dx            ;Save starting I/O addr
  21. ;
  22. ;First, disable any serial interrupts 
  23. ;
  24.         add    dx,4            ;Point to modem ctl reg
  25.         in    al,dx
  26.         push    ax
  27.         and    al,11111011b        ;Disable serial interrupt by
  28.         out    dx,al            ;  clearing Out 2 bit.
  29. ;
  30. ;Check for 8250 by checking for a scratch register at starting I/O + 7
  31. ;
  32.         mov    ch,0            ;Assume type 0
  33.         mov    dx,bx
  34.         add    dx,7            ;See if scratch reg exists
  35.         mov    al,55h
  36.         cli
  37.         out    dx,al
  38.         jmp    $+2
  39.         in    al,dx
  40.         cmp    al,55h
  41.         jne    sertype_1
  42.         mov    al,0aah
  43.         out    dx,al
  44.         jmp    $+2
  45.         in    al,dx
  46.         sti
  47.         cmp    al,0aah
  48.         jne    sertype_1
  49. ;
  50. ;Now check for FIFO mode to determine if 16550A
  51. ;
  52.         inc    ch            ;Assume type 1
  53.         mov    dx,bx
  54.         add    dx,2             ;Point to FIFO ctl reg
  55.         mov    al,7            ;Attempt to enable FIFOs
  56.         cli
  57.         out    dx,al
  58.         jmp    $+2
  59.         in    al,dx            ;Read interrupt ID reg
  60.         sti
  61.         and    al,0c0h            ;Strip all but FIFO bits
  62.         jz    sertype_1        ;If bits 0, 16450 or 16550
  63. ;
  64. ;Check for Type 3 DMA port by enabling DMA mode 
  65. ;
  66.         inc    ch            ;Assume type 2
  67.         mov    dx,bx
  68.         add    dx,8003h        ;Point to enhanced reg 1
  69.         cli
  70.         in    al,dx
  71.         push    ax
  72.         or    al,01000000b        ;Enable DMA transmit mode
  73.         out    dx,al
  74.         push    dx
  75.         mov    dx,bx
  76.         add    dx,2
  77.         in    al,dx
  78.         mov    cl,al
  79.         pop    dx            ;Restore Enhanced reg 1
  80.         pop    ax
  81.         out    dx,al
  82.         sti
  83.         and    cl,0c0h            ;Again mask all but FIFO ID
  84.         cmp    cl,40h
  85.         jne    sertype_1
  86.         inc    ch            ;Must be type 3 
  87. sertype_1:
  88.         pop    ax
  89.         mov    dx,bx
  90.         add    dx,4            ;Point to modem ctl reg
  91.         out     dx,al            ;Restore initial condition
  92.         mov    al,ch
  93.         mov    dx,bx
  94.         pop    cx
  95.         pop    bx
  96.         ret
  97. sertype        endp
  98.